package handel

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
	"zc/api/pkg"
)

func FileName(c *gin.Context) {
	// 单文件
	file, _ := c.FormFile("file")
	log.Println(file.Filename)

	dst := "../img/" + file.Filename
	// 上传文件至指定的完整文件路径
	pkg.FileName(file.Filename)
	c.SaveUploadedFile(file, dst)
	c.JSON(http.StatusOK, gin.H{"code": "200", "msg": "上传成功", "data": dst})
	c.String(http.StatusOK, fmt.Sprintf("'%s' uploaded!", file.Filename))
}
